public class Solution201 {
    /*public int rangeBitwiseAnd(int left, int right) {
        if (left == 0) {
            return 0;
        }
        if (right >> 1 >= left) {
            return 0;
        }
        int res = left;
        for (int i = left; i < right; i++) {
            res &= i;
        }
        res &= right;
        return res;
    }*/
    public int rangeBitwiseAnd(int m, int n) {
        int shift = 0;
        // 找到公共前缀
        while (m < n) {
            m >>= 1;
            n >>= 1;
            ++shift;
        }
        return m << shift;
    }
}
